<?php
/**
 * PostController.php file.
 *
 * @author Yufan <nimanyi@gmail.com>
 * @link http://www.dedecms.cn/
 * @copyright Copyright &copy; 2010-2012 Yufan Software LLC
 * @license http://www.dedecms.cn/license/
 * @version $Id: PostController.php 2011-12-7 20:13:57 Yufan $
 * @since 1.0
 */
class PostController extends  BaseController {
    public function actionIndex() {
        $criteria=new CDbCriteria;
        $criteria->with=array('commentCount','cate');
        if(isset($_GET['tag']))
            $criteria->addSearchCondition('tags',$_GET['tag']);
        $pages=new CPagination(Posts::model()->count($criteria));
        $pages->pageSize=!param("limit")?param("limit"):"10";
        $pages->applyLimit($criteria);
        $model=Posts::model()->published()->findAll($criteria);
        $this->render('index',array(
                'model'=>$model,
                'pages'=>$pages,
        ));
    }
}
?>
